package controller;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

import mock.PizzaMock;
import model.Pizza;

@ManagedBean
@SessionScoped
public class OrderList {


	private  DataModel<Pizza> orderList;
	private  DataModel<Pizza> cartContainer;
	private  List<Pizza> cart ;
	

	public DataModel<Pizza> getCartContainer() {
		return cartContainer;
	}


	public void setCartContainer(DataModel<Pizza> cartContainer) {
		this.cartContainer = cartContainer;
	}


	public List<Pizza> getCart() {
		return cart;
	}


	public void setCart(ArrayList<Pizza> cart) {
		this.cart = cart;
	}


	public DataModel<Pizza> getOrderList() {
		return orderList;
	}


	public void setOrderList(DataModel<Pizza> orderList) {
		this.orderList = orderList;
	}

	private int selectedIndex;
	
	public OrderList() {
		orderList = new ListDataModel<Pizza>();
		
		cart = new ArrayList<Pizza>();
		List<Pizza> pizzasMock = PizzaMock.pizzaList();
		orderList.setWrappedData(pizzasMock);
		
	}
	

	public int getSelectedIndex() {
		return selectedIndex;
	}

	public void setSelectedIndex(int selectedIndex) {
		this.selectedIndex = selectedIndex;
	}
	
	public void addToCart(ActionEvent event){
		cart.add(orderList.getRowData());
		cartContainer = new ListDataModel<Pizza>();
		cartContainer.setWrappedData(cart);
	}
	
	
	
}
